const router = require('koa-joi-router')
const picture = router()
const Joi = router.Joi
const searchController = require('../controller/search')
// picture.prefix('/search')
picture.route({
  method: 'get',
  path: '/search',
  validate: {
    query: {
      platform: Joi.number().allow(null).allow('').default(0), // 0 web 1 iOS 2 android
      keyword: Joi.string().min(1).max(100).trim().required(),
      page: Joi.number().default(1),
      page_size: Joi.number().default(20)
    }
  },
  handler: [searchController.filterKeyword, searchController.search]
})

picture.route({
  method: 'get',
  path: '/complete/search',
  validate: {
    query: {
      q: Joi.string().min(1).max(100).trim().required()
    }
  },
  handler: [searchController.complete]
})

picture.route({
  method: 'get',
  path: '/hotword',
  validate: {
  },
  handler: [searchController.hotword]
})

module.exports = picture
